<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
	<meta content="yes" name="apple-mobile-web-app-capable" />
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<meta content="telephone=no" name="format-detection" />
	<meta content="emai=no" name="format-detection" />
	<link rel="stylesheet" type="text/css" href="/wc/css/common.css" />
	<link rel="stylesheet" type="text/css" href="/wc/css/form.css" />
	<script type="text/javascript" src="/wc/js/jquery-1.11.2.min.js"></script>
	<script type="text/javascript" src="/wc/js/underscore.js"></script>
	<script type="text/javascript" src="/wc/js/pinchzoom.js"></script>
	<title>芝士妈妈在线</title>
	<script type="text/javascript">
		(function (m, ei, q, i, a, j, s) {
			m[a] = m[a] || function () {
				(m[a].a = m[a].a || []).push(arguments)
			};
			j = ei.createElement(q),
				s = ei.getElementsByTagName(q)[0];
			j.async = true;
			j.charset = 'UTF-8';
			j.src = i + '?v=' + new Date().getUTCDate();
			s.parentNode.insertBefore(j, s);
		})(window, document, 'script', '//static.meiqia.com/dist/meiqia.js', '_MEIQIA');
		_MEIQIA('entId', '20405');
		_MEIQIA('withoutBtn');
		_MEIQIA('init');
	</script>
	<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<script type="text/javascript">
	//调用微信JS api 支付
	function jsApiCall(id)
	{
		WeixinJSBridge.invoke(
			'getBrandWCPayRequest',
			<?php echo $jsApiParameters; ?>,
			function(res){
				WeixinJSBridge.log(res.err_msg);
// 				alert(res.err_code+res.err_desc+res.err_msg);
				if(res.err_msg == 'get_brand_wcpay_request:ok')
				{
					$.ajax({
						url: "/sale/order/changestatus",
						type: "post",
						data: {'id': id},
						success: function(msg){
							window.location.href = "/sale/order/success?id="+id;
						}
					});
				}
			}
		);
	}

	function callpay(id)
	{
		//ajax提交数据保存

		if (typeof WeixinJSBridge == "undefined"){
		    if( document.addEventListener ){
		        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
		    }else if (document.attachEvent){
		        document.attachEvent('WeixinJSBridgeReady', jsApiCall);
		        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
		    }
		}else{
		    jsApiCall(id);
		}
	}

	</script>

    <script>
        $(document).ready(function(){

            $("button[type='submit']").click(function (e) {
                e.preventDefault();
                validation();
            });

			
            function validation() {
                zsmm.isValidated = true;
				validateInput("name");
				validateSelect("idcard_type");
				validateCardNumber("cardnumber", $("#idcard_type").val());
				validateInput("cardnumber");
				validateInput("birthday");
				validateInput("duedate");
				validateInput("mobile");
				validatePhone("mobile");
				validateSelect("collection");
//				validateSelect("doctor");

				zsmm.isValidated = false;

				//验证码校验
				$.ajax({
					url: "/sale/order/validcode",
					async: false,
					data: {mobile: $("#mobile").val(), code: $("#code").val()},
					type: "post",
					dataType: "json",
					success: function(res){
						if(res.error == 0)
						{
							zsmm.isValidated = true;
						}
						else
						{
							zsmm.Toast.New(res.msg);
						}
						
					}

				});

                if (zsmm.isValidated) {
                    //$("form").submit();
                    var name = $("#name").val();
                    var idcard = $("#cardnumber").val();
					var idcard_type = $("#idcard_type").val();
                    var birthday = $("#birthday").val();
                    var duedate = $("#duedate").val();
                    var mobile = $("#mobile").val();
                    var code = $("#code").val();
                    var collection = $("#collection").val();
//                  var doctor = $("#doctor").val();
                    //ajax更新数据
                    $.ajax({
                        url: "/sale/order/savedate",
                        type: "post",
                        dataType: "json",
                        data:{
                            'name': name,
                            'idcard':idcard,
							'idcard_type':idcard_type,
                            'birthday':birthday ,
                            'duedate':duedate,
                            'mobile':mobile,
                            'code':code,
                            'collection':collection
//                          'doctor':doctor
                            },
                        success: function(msg)
                        {
                            //callpay(msg);
							var data =msg;
							window.location.href="/wxpay/index?id="+data['booking_id']+"&order_id="+data['order_id'];
                        },
                        error: function (xhr, type)
                        {
                            alert("请重试！");
                        },
                    });
                }
            }


        });

    </script>
</head>
<body>
	<header class="nopadding">
		<?php if(@$row['status'] <= 1){}else{echo '<img class="fullScreen" src="/wc/img/d_notice.png" />';} ?>
	</header>
	<div class="wrapper">
		<form action="<?php echo $payUrl;?>" method="post">
		<input type="hidden" id="id" value="<?php echo $row['id']?>">
		</form>
		<?php if(@$row['status'] <= 1){echo '<h2>个人信息填写</h2>';}?>
		<section class="flex-wrapper flex-align-center special">
			<label>姓名：</label>
			<p class="flex-1">
				<input type="text" id="name" name="name" value="<?php echo @$row['name']?>" data-message="请输入姓名！" />
			</p>
		</section>
		<section class="flex-wrapper flex-align-center special">
			<label>证件类型：</label>
			<p class="flex-1">
				<select class="special" id="idcard_type" name="idcard_type">
					<option value="1" <?php if(@$row['idcard_type'] == 1) echo 'selected = "selected"' ?> >身份证</option>
					<option value="2" <?php if(@$row['idcard_type'] == 2) echo 'selected = "selected"' ?> >港澳通行证</option>
					<option value="3" <?php if(@$row['idcard_type'] == 3) echo 'selected = "selected"' ?> >台湾通行证</option>
					<option value="4" <?php if(@$row['idcard_type'] == 4) echo 'selected = "selected"' ?> >护照</option>
				</select>
			</p>
		</section>
		<section class="flex-wrapper flex-align-center special">
			<label>证件号码：</label>
			<p class="flex-1">
				<input type="text" id="cardnumber" name="cardnumber" value="<?php echo @$row['idcard']?>" data-message="请输入证件号码！" />
			</p>
		</section>
		<section class="flex-wrapper flex-align-center special">
			<label>出生年月：</label>
			<p class="flex-1">
				<input type="date" id="birthday" name="birthday" value="<?php echo @$row['birthday']?>" data-message="请输入出生年月！" />
			</p>
		</section>
		<section class="flex-wrapper flex-align-center special">
			<label>预产期：</label>
			<p class="flex-1">
				<input type="date" id="duedate" name="duedate" value="<?php echo @$row['childbirth_date']?>" data-message="请输入预产期！" />
			</p>
		</section>
		<section class="flex-wrapper flex-align-center special">
			<label>手机号：</label>
			<p class="flex-1">
				<input type="tel" maxlength="13" id="mobile" name="mobile" value="<?php echo @$row['mobile']?>" data-message="请输入手机号！" />
			</p>
		</section>
		<section class="flex-wrapper flex-align-center nopadding">
			<label><button type="button" id="geticode" name="geticode" class="special">获取验证码</button></label>
			<p class="flex-1">
				<input type="number" maxlength="6" id="code" name="code" value="" placeholder="请输入验证码" data-message="请输入验证码！" />
			</p>
		</section>
		<h2>采血点</h2>
		<section class="nopadding">
			<select class="special" id="collection" name="collection">
				<?php foreach($bpointList as $key=>$value) { ?>
					<option value="<?php echo $value['id'] ?>" <?php if(@$row['bpoint_id'] == $value['id']) echo 'selected = "selected"' ?>><?php echo $value['name'] ?></option>
				<?php } ?>

			</select>
		</section>
		<!--<h2>推荐医生</h2>
		<section class="nopadding">
			<select class="special" id="doctor" name="doctor">
				<?php foreach($doctorList as $key=>$value) { ?>
					<option value="<?php echo $value['d_id'] ?>"  <?php if(@$row['doctor_id'] == $value['id']) echo 'selected = "selected"' ?>><?php echo $value['real_name'] ?></option>
				<?php } ?>
			</select>
			<p class="notice">（提示：您的推荐医生将第一时间获取您的检测状态）</p>
		</section>-->
		<h2>预约费用：&yen;200.00元</h2>
		<p class="notice">（凭预约单手机号码可直接抵扣检测费用）</p>
		<button type="submit" class="btn btn-red" id="savedate">付款预约</button>

		<?php if(@$row['status'] <= 1){}else{echo '<ul class="help flex-wrapper flex-pack-justify">
			<li><a href="javascript:void(0)" onclick="_MEIQIA(\'showPanel\')"><img src="/wc/img/d_online.png" /></a></li>
			<li><a href="tel:4008210418"><img src="/wc/img/d_phone.png" /></a></li>
		</ul>';} ?>


	</div>
	<footer>
		<ul>
			<li>
				<a href="/booking" class="btn btn-orange"><span class="icon icon-home"></span>首 页</a>
			</li>
			<li>
				<a id="showMap" class="btn btn-green"><span class="icon icon-blood"></span>采 血 点</a>
			</li>
			<li>
				<a href="/booking/mine" class="btn btn-red"><span class="icon icon-test"></span>我的检测</a>
			</li>
		</ul>
		
	</footer>
	<div class="hide popup-map">
		<div class="pinch-zoom">
			<img src="/wc/img/map.jpg" alt="" />
		</div>
	</div>
	<script src="/wc/js/common.js" type="text/javascript"></script>
	<script src="/wc/js/form_booking.js" type="text/javascript"></script>
</body>
</html>
